<?php
class Hotel{
	public $id_hotel;
	public $nom_hotel;
	public $telephone_hotel;
	public $description_hotel;
	public $site_hotel;
	public $nombre_etoile;
	public $nombre_chambre;
	public $email_hotel;
	
	
	public function __construct($donnee){
		$this->hydrate($donnee);
		if(empty($this->site_hotel))
			$this->site_hotel = "";
		if(empty($this->email_hotel))
			$this->email_hotel ="";
	}
	public function setId_hotel($id){
		if(is_int($id))
			$this->id_hotel = $id;
	}
	public function setNom_hotel($nom){
		if(is_string($nom))
			$this->nom_hotel = $nom	;
	}
	public function setTelephone_hotel($tel){
		if(is_string($tel))
			$this->telephone_hotel = $tel;
	}
	public function setEmail_hotel($email){
		$this->email_hotel = $email;	
	}
	public function setDescription_hotel($desc){
		if(is_string($desc))
			$this->description_hotel = $desc;	
	}
	public function setSite_hotel($site){
		if(is_string($site))
			$this->site_hotel = $site;	
	}
	public function setNombre_chambre($chambre){
		$this->nombre_chambre = (int)$chambre;	
	}
	public function setNombre_etoile($etoile){
		$this->nombre_etoile = (int)$etoile;	
	}
	public function hydrate(array $donnees1){
		
  		foreach ($donnees1 as $key => $value){
   		 // On récupère le nom du setter correspondant à l'attribut.
   		 $method = 'set'.ucfirst($key);
         
   		 // Si le setter correspondant existe.
    	if (method_exists($this, $method)){
     	 // On appelle le setter.
     	 $this->$method($value);
		}
  	}
	}
}